def fib_generator(n):
    a, b = 0, 1
    for _ in range(n):
        yield a
        a, b = b, a + b


def fib_list(n):
    if n <= 0:
        return []  # 对于非正整数输入，返回空列表
    return list(fib_generator(n))


def main():
    try:
        num = int(input("请输入一个数字："))
        if num <= 0:
            print("输入不合法，请输入一个正整数")
        else:
            fib_sequence = fib_list(num)
            print(f"前{num}个斐波那契数列为：{fib_sequence}")
    except ValueError:
        print("输入不合法，请输入一个有效的整数")


if __name__ == '__main__':
    main()